/**
 * Quick signin form validation
 * 
 */
function quickSignInVal() {
  $(document).ready(function() {
    $('#quick_sign_in_form').bootstrapValidator({
      live: 'disabled',
      message: '',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
        $('#quick_sign_in_dropdown').removeClass('open');
        $("#quick_sign_in_form").trigger('reset');
      },
      fields: {
        user_email: {
          validators: {
            notEmpty: {
            },
            emailAddress: {
            }
          }
        },
        user_password: {
          validators: {
            notEmpty: {
            }
          }
        }
      }
    });
  });
}

/**
 * Quick location form validation
 * 
 */
function quickLocationVal() {
  $(document).ready(function() {
    $('#quick_loc_form').bootstrapValidator({
      live: 'disabled',
      message: '',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        location_name: {
          validators: {
            notEmpty: {
            }
          }
        }
      }
    });
  });
}

/**
 * Quick Search form validation
 * 
 */
function quickSearchVal() {
  $(document).ready(function() {
    $('#quick_search_form').bootstrapValidator({
      live: 'disabled',
      message: '',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        search_term: {
          validators: {
            notEmpty: {
            }
          }
        }
      }
    });
  });
}

/**
 * Sign in form validation
 * 
 */
function signInVal() {
  $(document).ready(function() {
    $('#sign_in_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_email: {
          validators: {
            notEmpty: {
              message: 'Email is required'
            },
            emailAddress: {
              message: 'Email is invalid'
            }
          }
        },
        user_password: {
          validators: {
            notEmpty: {
              message: 'Password is required'
            }
          }
        },
        user_security_answer: {
          validators: {
            notEmpty: {
              message: 'Security answer is required'
            },
            digits: {
              message: 'Security answer is invalid'
            }
          }
        }
      }
    });
  });
}

/**
 * Sign up init form validation
 * 
 */
function signUpVal() {
  $(document).ready(function() {
    $('#sign_up_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_email: {
          validators: {
            notEmpty: {
              message: 'Email is required'
            },
            emailAddress: {
              message: 'Email is invalid'
            },
            stringLength: {
              max: 100,
              message: 'Email is invalid. Maximum 100 characters.'
            }
          }
        },
        user_security_answer: {
          validators: {
            notEmpty: {
              message: 'Security answer is required'
            },
            digits: {
              message: 'Security answer is invalid'
            }
          }
        }
      }
    });
  });
}

/**
 * Sign up complete form validation
 * 
 */
function signUpCompleteVal() {
  $(document).ready(function() {
    $('#sign_up_complete_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_email: {
          validators: {
            notEmpty: {
              message: 'Email is required'
            },
            emailAddress: {
              message: 'Email is invalid'
            },
            stringLength: {
              max: 100,
              message: 'Email is invalid. Maximum 100 characters.'
            }
          }
        },
        user_password: {
          validators: {
            notEmpty: {
              message: 'Password is required'
            },
            stringLength: {
              min: 5,
              message: 'Password is invalid. Minimum 5 characters'
            }
          }
        },
        user_zipcode: {
          validators: {
            notEmpty: {
              message: 'Zip / Pin code is required'
            },
            digits: {
              message: 'Zip / Pin code is invalid'
            }
          }
        },
        user_terms: {
          validators: {
            notEmpty: {
              message: 'Terms & Conditions must be accepted'
            }
          }
        }
      }
    });
  });
}

/**
 * Password reset form validation
 * 
 */
function passwordResetVal() {
  $(document).ready(function() {
    $('#password_reset_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_email: {
          validators: {
            notEmpty: {
              message: 'Email is required'
            },
            emailAddress: {
              message: 'Email is invalid'
            }
          }
        },
        user_security_answer: {
          validators: {
            notEmpty: {
              message: 'Security answer is required'
            },
            digits: {
              message: 'Security answer is invalid'
            }
          }
        }
      }
    });
  });
}

/**
 * Password reset change form validation
 * 
 */
function passwordResetChangeVal() {
  $(document).ready(function() {
    $('#password_reset_change_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_password: {
          validators: {
            notEmpty: {
              message: 'Password is required'
            },
            stringLength: {
              min: 5,
              message: 'Password is invalid. Minimum 5 characters'
            },
            identical: {
              field: 'user_password_confirm',
              message: 'Password and confirm password are not same'
            }
          }
        },
        user_password_confirm: {
          validators: {
            notEmpty: {
              message: 'Confirm password is required'
            },
            stringLength: {
              min: 5,
              message: 'Confirm password is invalid. Minimum 5 characters'
            },
            identical: {
              field: 'user_password',
              message: 'Password and confirm password are not same'
            }
          }
        }
      }
    });
  });
}

/**
 * Profile Edit - Settings
 * 
 * @returns {undefined}
 */
function settingsProfileVal() {
  $(document).ready(function() {
    $('#profile_edit_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_display_name: {
          validators: {
            notEmpty: {
              message: 'Name is required'
            },
            stringLength: {
              max: 50,
              message: 'Name is invalid. Maximum 50 characters.'
            }
          }
        },
        user_locality: {
          validators: {
            notEmpty: {
              message: 'Locality is required'
            },
            stringLength: {
              max: 50,
              message: 'Locality is invalid. Minimum 50 characters'
            }
          }
        },
        user_phone_number: {
          validators: {
            digits: {
              message: 'Phone Number is invalid'
            }
          }
        },
        user_mobile_number: {
          validators: {
            digits: {
              message: 'Phone Number is invalid'
            }
          }
        }
      }
    });
  });
}

/**
 * Settings Photo Validation
 * 
 * @returns {undefined}
 */
function settingsPhotoVal() {
  $(document).ready(function() {
    $('#settings_photo_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_image_uploaded: {
          validators: {
            notEmpty: {
              message: 'Image file is required'
            }
          }
        }
      }
    });
  });
}

/**
 * Password Settings Validation
 * 
 * @returns {undefined}
 */
function settingsPasswordVal() {
  $(document).ready(function() {
    $('#settings_password_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        user_password_current: {
          validators: {
            notEmpty: {
              message: 'Current password is required'
            },
            stringLength: {
              min: 5,
              message: 'Current password is invalid. Minimum 5 characters'
            }
          }
        },
        user_password_new: {
          validators: {
            notEmpty: {
              message: 'New password is required'
            },
            stringLength: {
              min: 5,
              message: 'New password is invalid. Minimum 5 characters'
            },
            identical: {
              field: 'user_password_new_confirm',
              message: 'New password and confirm password are not same'
            }
          }
        },
        user_password_new_confirm: {
          validators: {
            notEmpty: {
              message: 'Confirm password is required'
            },
            stringLength: {
              min: 5,
              message: 'Confirm password is invalid. Minimum 5 characters'
            },
            identical: {
              field: 'user_password_new',
              message: 'Password and confirm password are not same'
            }
          }
        }
      }
    });
  });
}

/**
 * Privacy Settings Validation
 * 
 * @returns {undefined}
 */
function settingsPrivacyVal() {
  $(document).ready(function() {
    $('#settings_privacy_form').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        email_privacy: {
          validators: {
            notEmpty: {
              message: 'Email privacy is required'
            }
          }
        },
        phone_privacy: {
          validators: {
            notEmpty: {
              message: 'Phone privacy is required'
            }
          }
        },
        social_privacy: {
          validators: {
            notEmpty: {
              message: 'Social privacy is required'
            }
          }
        }
      }

    });
  });
}

/**
 * Publish Advert
 * 
 * @returns {undefined}
 */
function publishAdvertVal() {
  $(document).ready(function() {
    $('#publish_advert').bootstrapValidator({
      live: 'disabled',
      message: 'This value is not valid',
      submitHandler: function(validator, form) {
        submitAjaxForm(form);
      },
      fields: {
        advert_category: {
          validators: {
            notEmpty: {
              message: 'Category is required'
            }
          }
        },
        advert_type: {
          validators: {
            notEmpty: {
              message: 'Type is required'
            }
          }
        },
        advert_title: {
          validators: {
            notEmpty: {
              message: 'Title is required'
            }
          }
        },
        advert_description: {
          validators: {
            notEmpty: {
              message: 'Description is required'
            }
          }
        },
        advert_price_value: {
          validators: {
            notEmpty: {
              message: 'Amount is required'
            },
            digits: {
              message: 'Amount is invalid'
            }
          }
        },
        advert_zip_code: {
          validators: {
            notEmpty: {
              message: 'Zip / Pin code is required'
            },
            digits: {
              message: 'Zip / Pin code is invalid'
            }
          }
        },
        advert_locality: {
          validators: {
            notEmpty: {
              message: 'Locality are required'
            }
          }
        },
        advert_images_uploaded: {
          validators: {
            notEmpty: {
              message: 'Images are required'
            }
          }
        }
      }
    });
  });
}